home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers1.zip / LINE.ASM < prev    next >
Assembly Source File  |  1992-01-17  |  1KB  |  82 lines

  1. ;put into the public domain by Russell Nelson, nelson@crynwr.com
  2. ;requires pixel.asm
  3.  
  4. x_inc        dw    ?        ;either move_left or move_right
  5. y_inc        dw    ?        ;either move_up or move_down
  6. larger_delta    dw    ?
  7. smaller_delta    dw    ?
  8. line_color    db    ?
  9.  
  10. line:
  11.     mov    line_color,al
  12.     mov    ax,move_right
  13.     mov    x_inc,ax
  14.     mov    ax,move_down
  15.     mov    y_inc,ax
  16.     sub    si,cx            ;si=delta x
  17.     sub    di,dx            ;di=delta y
  18.     or    si,si
  19.     jge    line_to_1
  20.     neg    si
  21.     mov    ax,move_left
  22.     mov    x_inc,ax
  23. line_to_1:
  24.     or    di,di
  25.     jge    line_to_2
  26.     neg    di
  27.     mov    ax,move_up
  28.     mov    y_inc,ax
  29. line_to_2:
  30.     cmp    si,di
  31.     jge    x_by_one
  32.  
  33. y_by_one:
  34. ;delta y >= delta x
  35.     mov    larger_delta,si
  36.     mov    smaller_delta,di
  37.     mov    si,di            ;use dx to test when dx is incremented
  38.     sar    si,1            ;/2
  39.     push    di
  40.     call    open_vid
  41.     pop    cx
  42.     inc    cx            ;include endpoint.
  43. y_by_one_1:
  44.     mov    al,line_color
  45.     call    set_bit
  46.     mov    bx,smaller_delta
  47.     add    si,larger_delta
  48.     cmp    si,bx            ;past the larger yet?
  49.     jl    y_by_one_2        ;no.
  50.     sub    si,bx            ;yes - subtract it off.
  51.     call    x_inc
  52. y_by_one_2:
  53.     call    y_inc
  54.     loop    y_by_one_1
  55.     call    close_vid
  56.     ret
  57.  
  58. x_by_one:
  59. ;delta x > delta y
  60.     mov    larger_delta,si
  61.     mov    smaller_delta,di
  62.     call    open_vid
  63.     mov    cx,si
  64.     inc    cx            ;include endpoint.
  65.     sar    si,1
  66. x_by_one_1:
  67.     mov    al,line_color
  68.     call    set_bit
  69.     mov    bx,larger_delta
  70.     add    si,smaller_delta
  71.     cmp    si,bx            ;past the larger yet?
  72.     jl    x_by_one_2        ;no.
  73.     sub    si,bx            ;larger.
  74.     call    y_inc
  75. x_by_one_2:
  76.     call    x_inc
  77.     loop    x_by_one_1
  78.     call    close_vid
  79.     ret
  80.  
  81.  
  82.